Skip to content

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Nov 9, 2024

#131186 implements some machinery to detect in borrowck when we may have RPIT overcaptures due to edition 2024, and suggests adding + use<'a, T> to go back to the edition 2021 capture rules. However, we weren't filtering out cases when there are APITs in scope.

This PR implements a more sophisticated diagnostic where we will suggest turning any APITs in scope into type parameters, and applies this to both the borrowck error note, and to the impl_trait_overcaptures migration lint.

cc #132809

@rustbot
Copy link
Collaborator

rustbot commented Nov 9, 2024

r? @jieyouxu

rustbot has assigned @jieyouxu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 9, 2024
@@ -1792,6 +1793,130 @@ impl Subdiagnostic for AddPreciseCapturingAndParams {
self.suggs,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cribbed a lot of the diagnostics logic from this subdiagnostic I previously implemented; unfortunately, not enough logic is common enough for this to be shared :/

Comment on lines +127 to +128
LL | fn apit2<U, T: Sized>(_: &T, _: U) -> impl Sized + use<U, T> {}
| ++++++++++ ~ +++++++++++
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T: Sized is a bit meh but also I literally dgaf b/c it's still valid.

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks like a reasonable suggestion to me, it's perfectly fine (heh) if it's not perfect.

@jieyouxu
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Nov 10, 2024

📌 Commit a1f9d5b has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 10, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 10, 2024
…iaskrgr

Rollup of 2 pull requests

Successful merges:

 - rust-lang#132136 (ABI compatibility: remove section on target features)
 - rust-lang#132816 (Dont suggest `use<impl Trait>` when we have an edition-2024-related borrowck issue)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c1f3c70 into rust-lang:master Nov 10, 2024
6 checks passed
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 10, 2024
Rollup merge of rust-lang#132816 - compiler-errors:2024-apit, r=jieyouxu

Dont suggest `use<impl Trait>` when we have an edition-2024-related borrowck issue

rust-lang#131186 implements some machinery to detect in borrowck when we may have RPIT overcaptures due to edition 2024, and suggests adding `+ use<'a, T>` to go back to the edition 2021 capture rules. However, we weren't filtering out cases when there are APITs in scope.

This PR implements a more sophisticated diagnostic where we will suggest turning any APITs in scope into type parameters, and applies this to both the borrowck error note, and to the `impl_trait_overcaptures` migration lint.

cc rust-lang#132809
@rustbot rustbot added this to the 1.84.0 milestone Nov 10, 2024
mati865 pushed a commit to mati865/rust that referenced this pull request Nov 12, 2024
Dont suggest `use<impl Trait>` when we have an edition-2024-related borrowck issue

rust-lang#131186 implements some machinery to detect in borrowck when we may have RPIT overcaptures due to edition 2024, and suggests adding `+ use<'a, T>` to go back to the edition 2021 capture rules. However, we weren't filtering out cases when there are APITs in scope.

This PR implements a more sophisticated diagnostic where we will suggest turning any APITs in scope into type parameters, and applies this to both the borrowck error note, and to the `impl_trait_overcaptures` migration lint.

cc rust-lang#132809
mati865 pushed a commit to mati865/rust that referenced this pull request Nov 12, 2024
…iaskrgr

Rollup of 2 pull requests

Successful merges:

 - rust-lang#132136 (ABI compatibility: remove section on target features)
 - rust-lang#132816 (Dont suggest `use<impl Trait>` when we have an edition-2024-related borrowck issue)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants